﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using websoniBO;

namespace websoni.Adminpages
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        Album al = new Album();
        Gallery g = new Gallery();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = al.GetRecords(-99, "", "", false, " and");
                ddalbum.DataSource = dt;
                ddalbum.DataTextField = "album_name";
                ddalbum.DataValueField = "alid";
                ddalbum.DataBind();

                DataList1.DataSource = dt;
                DataList1.DataBind();

                DataTable dt1 = g.GetRecords(-99,Convert.ToInt64(Request["id"]), "", "", false, " and ");
                DataList2.DataSource = dt1;
                DataList2.DataBind();


                
            }

        }

        protected void btnok_Click(object sender, EventArgs e)
        {
            al.alid = -99;
            al.album_name = tbname.Text;
            if(uploadcover.HasFile)
                uploadcover.PostedFile.SaveAs(Server.MapPath("~/images/"+uploadcover.FileName));
            al.front = uploadcover.FileName;
            al.isdeleted = false;
            al.SaveRecords();
            Response.Redirect("~/Adminpages/Ag.aspx");
        }

        protected void btn1ok_Click(object sender, EventArgs e)
        {
            g.gid = -99;
            g.alid = Convert.ToInt64(ddalbum.SelectedValue.ToString());
            if(uploadphoto.HasFile)
                uploadphoto.PostedFile.SaveAs(Server.MapPath("~/images/"+uploadphoto.FileName));
            g.images = uploadphoto.FileName;
            g.image_description = tbdescription.Text;
            g.isdeleted = false;
            g.SaveRecords();
            Response.Redirect("~/Adminpages/Ag.aspx");
        }
    }
}
